\doxysection{cr\+QUEUE\+\_\+\+SEND }
\hypertarget{group__cr_q_u_e_u_e___s_e_n_d}{}\label{group__cr_q_u_e_u_e___s_e_n_d}\index{crQUEUE\_SEND@{crQUEUE\_SEND}}

\begin{DoxyPre}
crQUEUE\_SEND(                  CoRoutineHandle\_t xHandle,                  QueueHandle\_t pxQueue,                  void *pvItemToQueue,                  TickType\_t xTicksToWait,                  BaseType\_t *pxResult             )\end{DoxyPre}


The macro\textquotesingle{}s cr\+QUEUE\+\_\+\+SEND() and cr\+QUEUE\+\_\+\+RECEIVE() are the co-\/routine equivalent to the x\+Queue\+Send() and x\+Queue\+Receive() functions used by tasks.

cr\+QUEUE\+\_\+\+SEND and cr\+QUEUE\+\_\+\+RECEIVE can only be used from a co-\/routine whereas x\+Queue\+Send() and x\+Queue\+Receive() can only be used from tasks.

cr\+QUEUE\+\_\+\+SEND can only be called from the co-\/routine function itself -\/ not from within a function called by the co-\/routine function. This is because co-\/routines do not maintain their own stack.

See the co-\/routine section of the WEB documentation for information on passing data between tasks and co-\/routines and between ISR\textquotesingle{}s and co-\/routines.


\begin{DoxyParams}{Parameters}
{\em x\+Handle} & The handle of the calling co-\/routine. This is the x\+Handle parameter of the co-\/routine function.\\
\hline
{\em px\+Queue} & The handle of the queue on which the data will be posted. The handle is obtained as the return value when the queue is created using the x\+Queue\+Create() API function.\\
\hline
{\em pv\+Item\+To\+Queue} & A pointer to the data being posted onto the queue. The number of bytes of each queued item is specified when the queue is created. This number of bytes is copied from pv\+Item\+To\+Queue into the queue itself.\\
\hline
{\em x\+Tick\+To\+Delay} & The number of ticks that the co-\/routine should block to wait for space to become available on the queue, should space not be available immediately. The actual amount of time this equates to is defined by config\+TICK\+\_\+\+RATE\+\_\+\+HZ (set in \doxylink{_free_r_t_o_s_config_8h_source}{Free\+RTOSConfig.\+h}). The constant port\+TICK\+\_\+\+PERIOD\+\_\+\+MS can be used to convert ticks to milliseconds (see example below).\\
\hline
{\em px\+Result} & The variable pointed to by px\+Result will be set to pd\+PASS if data was successfully posted onto the queue, otherwise it will be set to an error defined within \doxylink{projdefs_8h_source}{Proj\+Defs.\+h}.\\
\hline
\end{DoxyParams}
Example usage\+: 
\begin{DoxyPre}
// Co-\/routine function that blocks for a fixed period then posts a number onto
// a queue.
static void prvCoRoutineFlashTask( CoRoutineHandle\_t xHandle, UBaseType\_t uxIndex )
\{
// Variables in co-\/routines must be declared static if they must maintain value across a blocking call.
static BaseType\_t xNumberToPost = 0;
static BaseType\_t xResult;

   // Co-\/routines must begin with a call to crSTART().
   crSTART( xHandle );

   for( ;; )
   \{
       // This assumes the queue has already been created.
       crQUEUE\_SEND( xHandle, xCoRoutineQueue, \&xNumberToPost, NO\_DELAY, \&xResult );

       if( xResult != pdPASS )
       \{
           // The message was not posted!
       \}

       // Increment the number to be posted onto the queue.
       xNumberToPost++;

       // Delay for 100 ticks.
       crDELAY( xHandle, 100 );
   \}

   // Co-\/routines must end with a call to crEND().
   crEND();
\}\end{DoxyPre}
 